package cn.home.sysmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.sysmanagement.domain.HomeDoctorTeam;
import cn.home.sysmanagement.service.IHomeDoctorTeamService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 医生-团队Controller
 * 
 * @author homedoctor
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/sysmanagement/doctorteam")
public class HomeDoctorTeamController extends BaseController
{
    @Autowired
    private IHomeDoctorTeamService homeDoctorTeamService;

    /**
     * 查询医生-团队列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeDoctorTeam homeDoctorTeam)
    {
        startPage();
        List<HomeDoctorTeam> list = homeDoctorTeamService.selectHomeDoctorTeamList(homeDoctorTeam);
        return getDataTable(list);
    }

    /**
     * 导出医生-团队列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:export')")
    @Log(title = "医生-团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeDoctorTeam homeDoctorTeam)
    {
        List<HomeDoctorTeam> list = homeDoctorTeamService.selectHomeDoctorTeamList(homeDoctorTeam);
        ExcelUtil<HomeDoctorTeam> util = new ExcelUtil<HomeDoctorTeam>(HomeDoctorTeam.class);
        util.exportExcel(response, list, "医生-团队数据");
    }

    /**
     * 获取医生-团队详细信息
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:query')")
    @GetMapping(value = "/{doctorId}")
    public AjaxResult getInfo(@PathVariable("doctorId") Long doctorId)
    {
        return success(homeDoctorTeamService.selectHomeDoctorTeamByDoctorId(doctorId));
    }
    /**
     * 获取医生-团队详细信息
     */
    @GetMapping(value = "/teamid/{teamId}")
    public AjaxResult getInfoByTeamId(@PathVariable("teamId") Long teamId)
    {
        return success(homeDoctorTeamService.selectHomeDoctorTeamByTeamId(teamId));
    }
    /**
     * 新增医生-团队
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:add')")
    @Log(title = "医生-团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeDoctorTeam homeDoctorTeam)
    {
        return toAjax(homeDoctorTeamService.insertHomeDoctorTeam(homeDoctorTeam));
    }


    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:query')")
    @GetMapping(value = "/byteamid/{teamId}")
    public AjaxResult getInfo2(@PathVariable("teamId") Long teamId)
    {
        return success(homeDoctorTeamService.selectHomeDoctorTeamByTeamId2(teamId));
    }
    /**
     * 修改医生-团队
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:edit')")
    @Log(title = "医生-团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeDoctorTeam homeDoctorTeam)
    {
        return toAjax(homeDoctorTeamService.updateHomeDoctorTeam(homeDoctorTeam));
    }

    /**
     * 删除医生-团队
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctorteam:remove')")
    @Log(title = "医生-团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{doctorIds}")
    public AjaxResult remove(@PathVariable Long[] doctorIds)
    {
        return toAjax(homeDoctorTeamService.deleteHomeDoctorTeamByDoctorIds(doctorIds));
    }
}
